Processing records in dynamic ranges

ABSTRACT

A scalable analysis system is described herein that performs common data analysis operations such as distinct counts and data grouping in a more scalable and efficient manner. The system allows distinct counts and data grouping to be applied to large datasets with predictable growth in the cost of the operation. The system dynamically partitions data based on the actual data distribution, which provides both scalability and uncompromised performance. The system sets a budget of available memory or other resources to use for the operation. As the operation progresses, the system determines whether the budget of memory is nearing exhaustion. Upon detecting that the memory used is near the limit, the system dynamically partitions the data. If the system still detects memory pressure, then the system partitions again, until a partition level is identified that fits within the memory budget.

CROSS-REFERENCE TO RELATED APPLICATION(S)

This application is a continuation of U.S. patent application Ser. No.14/805,349, filed Jul. 21, 2015, entitled “PROCESSING RECORDS IN DYNAMICRANGES,” which is a continuation of U.S. patent application Ser. No.13/092,978, filed Apr. 25, 2011, entitled “PROCESSING RECORDS IN DYNAMICRANGES,”. The entirety of each of these afore-mentioned applications isincorporated herein by reference.

BACKGROUND

Databases are used to store and process data for a variety of taskstoday. Businesses often use databases to manage customers, track sales,manage internal personnel and operations, and so forth. BusinessIntelligence (BI) refers to the use of databases or other systems toanalyze a business. The analysis may include observing historicaltrends, projecting future performance, slicing collected information(e.g., sales by region or by month), and so on. Databases often providequery functionality that facilitates the implementation of businessintelligence using data stored in a database and implemented byinformation technology (IT) or other personnel within a business.

Two common types of query operations are obtaining distinct counts ofitems in repetitive data and grouping data by some value. In terms ofStructured Query Language (SQL), these operations are invoked by the“DISTINCT COUNT” and “GROUP BY” keywords. A distinct count can be used,for example, to determine how many distinct customers purchased productsfrom a company during a period. Using a database table that contains arow for each purchase transaction and a column with a customeridentifier, a distinct count on the customer identifier will return thetotal number of customers that had transactions matching any othercriteria in the query (such as filtering conditions in the WHEREclause). Grouping collects related data together, and can be used toproduce subtotals or other sub-collections of data within a largercollection. For example, using the same transactions table, a query cangroup transactions by region to obtain a revenue per region thatcontributes to the overall revenue represented in the table. These twoconcepts can also be used together, such as to obtain a distinct countof customers in each region.

The most common problems with counting and grouping operations are thecomputational complexity and corresponding time involved with producingthe results. Determining a distinct count involves some level oftracking which values have been seen before so that additional data ofthat value can be ignored, and which values have not been seen so thatthe count can be incremented when new data values are encountered.Grouping data likewise involves tracking how many separate values of thegrouped data value exist, and partitioning rows that are found based onthe value of the grouped data value for each row. Performing these tasksmay involve sorting the data, creating temporary tables, building hashtables, pushing large data structures to disk or other large (but slow)storage, and so forth. These operations are costly in terms of time andstorage resources, and affect how large of a dataset can be used withsuch operations to achieve results in a reasonable period. Inparticular, datasets that have columns of high cardinality (i.e., manydifferent values in the set) present computational difficulties forexisting analysis systems.

SUMMARY

A scalable analysis system is described herein that performs common dataanalysis operations such as distinct counts and data grouping in a morescalable and efficient manner. The system allows distinct counts anddata grouping to be applied to large datasets with predictable growth inthe cost of the operation. The system dynamically partitions data basedon the actual data distribution, which provides both scalability anduncompromised performance. In some embodiments, the scalable analysissystem modifies an existing database infrastructure to allow columns tobe declared as partitionable and to add a BETWEEN operator to the WHEREclause that allows specifying an upper and lower bound of dataidentifiers (where a data identifier identifies a row) for a particularquery. Using these capabilities, the system begins with the assumptionthat a query will process the whole data set in one pass. The systemsets a budget of available memory or other resources to use for theoperation. As the operation progresses, the system determines whetherthe budget of memory is nearing exhaustion. Upon detecting that thememory used is near the limit, the system dynamically partitions thedata. If the system still detects memory pressure, then the systempartitions again, until a partition level is identified that fits withinthe memory budget.

After the system finishes processing the first partition, it complementsthe range values in the between operator and begins processing theremaining partition in the same manner. Depending on the values presentin the remaining partition, it is possible that the system will notpartition the data further (or conversely may partition the data to afurther extent than the first partition). In this way, the partitioningis initially optimistic. If the data has low cardinality, the system maycomplete the query with no partitioning. For data with high cardinality,the system may complete the query piece by piece, creating andprocessing multiple partitions. The system can complete the operation ina manner that is most efficient for the actual data on which theoperation is performed. Meanwhile, the resources consumed (e.g., memory)are predictable and local to the operation, allowing for fastprocessing.

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram that graphically illustrates the first phase of thescanning performed by the scalable analysis system, in one embodiment.

FIG. 2 is a block diagram that illustrates components of the scalableanalysis system, in one embodiment.

FIG. 3 is a flow diagram that illustrates processing of the scalableanalysis system to execute a query efficiently and without exceeding aspecified resource budget, in one embodiment.

FIG. 4 is a flow diagram that illustrates processing of the scalableanalysis to dynamically partition records in a data set while processinga query, in one embodiment.

DETAILED DESCRIPTION

A scalable analysis system is described herein that performs common dataanalysis operations such as distinct counts and data grouping in a morescalable and efficient manner. The system allows distinct counts anddata grouping to be applied to large datasets with predictable growth inthe cost of the operation. The classical strategy involves eitherpartitioning (i.e., sorting) the data by the distinct count column(s)and forward-only traversing this data, with the disadvantage thatsorting will involve extra time. A second common strategy is to build ahash table of all of the columns involved and then use the hash table asdata input for the operation, with the disadvantage that the hash tableis non-local and may spill onto disk (leading to thrashing and poorperformance). The scalable analysis system solves this problem by usinga multi-phase approach for grouping data (which is the first phase of adistinct count operation as well). The system dynamically partitionsdata based on the actual data distribution, which provides bothscalability and uncompromised performance.

In some embodiments, the scalable analysis system modifies an existingdatabase infrastructure to allow columns to be declared as partitionableand to add a BETWEEN operator to the WHERE clause that allows specifyingan upper and lower bound of data identifiers (where a data identifieridentifies a row) for a particular query. Using these capabilities, thesystem begins with the assumption that a query will process the wholedata set in one pass (e.g., the BETWEEN operator specifies the lowestand highest available values, such as 0 and 30M for a table of 30Mrecords). The system sets a budget of available memory to use for theoperation. As the operation progresses, the system determines whetherthe budget of memory is nearing exhaustion (e.g., detecting memorypressure). For example, if the memory budget is 100 megabytes (MB), thenthe system may take note as the consumed memory approaches that limit.Upon detecting that the memory used is near the limit, the systemdynamically partitions the data. For example, the system may initiallypartition the data in half, adjusting the upper bound of the BETWEENoperator to half the previous value. If the system still detects memorypressure, then the system partitions again (e.g., in thirds, so that thefirst one third of the records are being processed), until a partitionlevel is identified that fits within the memory budget.

After the system finishes processing the first partition, it complementsthe range values in the between operator and begins processing theremaining partition in the same manner. Depending on the values presentin the remaining partition, it is possible that the system will notpartition the data further (or conversely may partition the data to afurther extent than the first partition). Using the previous example,the system may process records 10M to 30M in one pass. In this way, thepartitioning is initially optimistic. If the data has low cardinality,the system may complete the query with no partitioning. For data withhigh cardinality, the system may complete the query piece by piece,creating and processing multiple partitions. The system can complete theoperation in a manner that is most efficient for the actual data onwhich the operation is performed. Meanwhile, the resources consumed(e.g., memory) are predictable and local to the operation, allowing forfast processing. Thus, the scalable analysis system performs scalableand efficient distinct count and grouping operations regardless of thedataset or distribution of the data.

In some embodiments, the scalable analysis system evaluates theconditions for partitioning every N records. When the condition isevaluated, if the data meets the conditions for partitioning (e.g.,based on memory pressure or other factors), then the system adjusts theupper bound of the current between value to introduce another data scan.For example, if the data contains 30M distinct values in a partitionablecolumn, the system might first attempt to partition the data with arange from zero to 15M (as this moves the number of scans from one totwo). Then, if after processing N more records the system determinesthat further partitioning is warranted, the system may attempt topartition 0 to 10M (moving the potential number of scans from two tothree). The system continues in this manner for each partition, untilall of the records specified for the query have been processed.

In some embodiments, the scalable analysis system implements the secondphase of a classic hash-based approach on top of this scheme. For eachpartition, the system processes data within the partition to determinethe number of distinct values or other operation specified by the query.The system may include an object model that provides the BETWEENoperator described above. To simplify the model and interactions, thesystem may default to creating the BETWEEN values for a WHERE clause onpartitionable columns. As results are completed for each partition, thesystem may provide the partial results to the consumer or internallystore the results for combination with those of other partitions toprovide a unified final result.

FIG. 1 is a diagram that graphically illustrates the first phase of thescanning performed by the scalable analysis system, in one embodiment.The diagram includes a timeline from top to bottom that shows a firsttime 110, a second time 120, a third time 130, and a fourth time 140during the processing of the system. At the first time 110, the systembegins the scan, initially assuming that the entire dataset can beprocessed in one pass without exceeding the memory budgeted for theoperation. At the second time 120, the system detects memory processorand partitions the data so that the first scan includes half of thedataset. At the third time 130, the system still detects memory pressureand further partitions the data so that the first can includes the firstthird of the dataset. At the fourth time 140, the first scan hascompleted, and the system begins processing of the second partition thatincludes the remaining two-thirds of the dataset. In the exampleillustrated, the system is able to complete processing of the secondpartition without detecting memory pressure and thus without furtherpartitioning the second partition. The data coverage 150 of each pass isillustrated, showing that the first partition covered records zero to10M and the second partition covered records 10M to 30M. Typically, thiskind of split indicates that the data in the first partition was moreskewed in value than that in the second partition.

FIG. 2 is a block diagram that illustrates components of the scalableanalysis system, in one embodiment. The system 200 includes a queryreceiving component 210, a range identification component 220, a budgetmanagement component 230, a dynamic partition component 240, a rangeprocessing component 250, a result management component 260, and a dataoutput component 270. Each of these components is described in furtherdetail herein.

The query receiving component 210 receives from a requestor a databasequery that operates over a target range of data. The component 210 mayreceive the query through a user interface, application-programminginterface, or other interface provided by the system 200 for accessingdata stored in a database. The database may include one or more serversand data storage devices that store data, as well as one or moresoftware modules that implement various internal and external operationsperformed by the database. Database implementation is well known in theart and is not explicitly covered here except where helpful to betterunderstand the operation of the system 200. The query receivingcomponent 210 may include a standard database query engine augmented toreceive certain new operators, such as the BETWEEN operator describedherein, and to identify information about data that is the subject ofthe query, such as partitionable columns described herein. The queryreceiving component 210 may receive a query in structured query languageor any other format suitable for accessing a database as describedherein.

The range identification component 220 identifies an initial rangerelated to the target range over which to partition the data for a firstpass to perform the received query. For example, if the query does notinclude an explicit indication of ranges, such as a BETWEEN operatorspecified by the requestor, then the system may identify the total rangeof data identifiers (e.g., row identifiers) affected by the query, anddivide the data identifiers initially into a partition that includes thewhole target range of data. In other words, the component 220 initiallyoptimistically assumes that the entire target range can be processed inone pass without exceeding resource budget threshold for the operation.The system 200 may also invoke the range identification component 220 toidentify remaining ranges of data in subsequent passes after dynamicpartitioning, described further below, has occurred.

The budget management component 230 receives a resource budget thresholdthat defines a limit of permissible resource usage by the receivedquery. The system 200 attempts to process the query quickly andefficiently, while staying within the received resource budgetthreshold. The component 230 may receive a budget that includes one ormore resources along with thresholds for each. For example, theresources may include memory usage, central processing unit (CPU) load,disk usage, whether or not paging to disk is allowed, or any otherresource related budget relevant to the query operation. In some cases,the system 200 may automatically define resource budgets in a mannerthat is not user configurable, while in other cases the system 200 mayreceive one or more thresholds from an administrator or from the queryrequestor. This allows any of the database manufacturer, systemadministrators, and users to be involved in the control of resourceusage as specific needs of a particular implementation demand. Thebudget management component 230 may receive the resource budget(s) aspart of the query or during an earlier configuration process (e.g., whenthe database is first set up).

The dynamic partition component 240 monitors resource usage by thedatabase during processing of the received query, compares the monitoredusage to the received resource budget threshold, and dynamicallypartitions a current range of data being processed to identify a subsetof data that can be handled within the received budget threshold. Thecurrent range of data being processed when partitioning occurs mayinclude the identified initial range of data or a subsequent partitionbeing processed by the range processing component 250. The dynamicpartition component 240 can use a variety of algorithms and heuristicsto determine how to partition individual ranges of data. In someembodiments, the component 240 cuts the range of data to process in halfupon the first detection of resource pressure. For example, if thesystem 200 initially attempts to optimistically process the entiretarget range of data and begins to notice that memory usage is exceedinga budget threshold, then the system may cut the target range in half,processing each half individually. If pressure does not easesufficiently, the component 240 may again partition the current rangefurther. For example, the component 240 may reduce the data to one-thirdof the target range, or may use a binary approach to cut the data inhalf again. In some embodiments, the system 200 provides configurableparameters for determining how the data range is partitioned when thesystem 200 detects resource pressure.

In some embodiments, the dynamic partition component 240 makespartitioning decisions that only affect the current range of data. Inother words, even though the component 240 determines that one-third orone-fourth of the target range of data will be processed in a particularpass, this does not necessarily mean that the remaining data will bedivided in the same amounts. The system 200 can dynamically make suchdecisions as those rows are processed. For example, it is entirelypossible that a first one-fourth of the data is processed in a firstpass and that a remaining three-quarters of the data is processed in asecond pass with no further divisions of the second partition. Thus, thenumber of partitions of any given range of data can be more a factor ofcardinality/skew or other properties of the data and how thoseproperties affect resource usage than by any artificially imposedcondition.

The range processing component 250 performs the received query onindividual partition ranges identified by the dynamic partitioncomponent 240. For example, if the dynamic partition component dividesthe target range into partitions comprising a first one-third, and alatter two-thirds of the target range, then the range processingcomponent 250 performs the query first on the initial one-third and thenlater on the latter two-thirds of the target range. Note that at anytime as the component 250 is processing the range, the system 200 maydetermine, via the dynamic partition component 240, that the data willbe further partitioned to stay within a budgeted resource level. Forexample, the resource level may ensure that a threshold level of memoryis not exceeded by the operation that would lead to paging memory todisk, which can dramatically slow the speed of processing the query.

The result management component 260 merges one or more processingresults of individual partition ranges generated by the range processingcomponent 250. The processing of each partition will produce results,and if there is more than one partition used to process a particulartarget range of data specified by a query, then those results willtypically need to be merged to generate a correct query result. Forexample, if the query performs a distinct count across many rows of datathat are processed in two partitions, then the result managementcomponent 260 combines the results of processing the first partitionwith those of processing the second partition to identify distinct datavalues across the entire target range of the data set specified by thequery. To give a more concrete example, assume that the query isdesigned to determine a dollar amount of goods sold to each continentduring a month and the rows of data represent individual salestransactions. If the system processes the data set in two partitions,the first partition may indicate $20,000 of sales to North America and$10,000 of sales to Europe, and the second partition may indicate$15,000 of sales to North America and $7,000 of sales to Europe. To geta correct result of the query, since the requestor is not interested inthe partitioning scheme used by the system 200 to efficiently processdata, the result management component 260 adds the results of processingthe two partitions to correctly report a total of $25,000 of sales toNorth America and $17,000 of sales to Europe.

The data output component 270 provides a query result to the requestorin response to the query. The query result includes rows or other dataresulting from processing the entire target range. The data outputcomponent 270 responds to the requestor in a manner consistent with howthe request was received. For example, if the system 200 received thequery though a user interface provided by the system 200, then the dataoutput component 270 reports the results to the user interface.Similarly, if the request came through an application-programminginterface or network request, then the data output component 270provides results in kind using the same interface.

The computing device on which the scalable analysis system isimplemented may include a central processing unit, memory, input devices(e.g., keyboard and pointing devices), output devices (e.g., displaydevices), and storage devices (e.g., disk drives or other non-volatilestorage media). The memory and storage devices are computer-readablestorage media that may be encoded with computer-executable instructions(e.g., software) that implement or enable the system. In addition, thedata structures and message structures may be stored or transmitted viaa data transmission medium, such as a signal on a communication link.Various communication links may be used, such as the Internet, a localarea network, a wide area network, a point-to-point dial-up connection,a cell phone network, and so on.

Embodiments of the system may be implemented in various operatingenvironments that include personal computers, server computers, handheldor laptop devices, multiprocessor systems, microprocessor-based systems,programmable consumer electronics, digital cameras, network PCs,minicomputers, mainframe computers, distributed computing environmentsthat include any of the above systems or devices, set top boxes, systemson a chip (SOCs), and so on. The computer systems may be cell phones,personal digital assistants, smart phones, personal computers,programmable consumer electronics, digital cameras, and so on.

The system may be described in the general context ofcomputer-executable instructions, such as program modules, executed byone or more computers or other devices. Generally, program modulesinclude routines, programs, objects, components, data structures, and soon that perform particular tasks or implement particular abstract datatypes. Typically, the functionality of the program modules may becombined or distributed as desired in various embodiments.

FIG. 3 is a flow diagram that illustrates processing of the scalableanalysis system to execute a query efficiently and without exceeding aspecified resource budget, in one embodiment. Beginning in block 310,the system receives a query that requests processing of a data set toproduce a query result. For example, the system operating at a databaseserver may receive a query request from one or more client computersover a network. The query specifies one or more columns of the data setor computed columns to return in the query result, as well as anyfilters that identify portions of the data set of interest to the queryrequestor. For example, the query may be provided in structured querylanguage in which a SELECT clause specifies the columns to return and aWHERE clause specifies filters that identify portions of the data set.The query may also include computed functions like the COUNT operator ordata grouping by including a GROUP BY clause.

Continuing in block 320, the system sets an initial record range toprocess that includes the entire portion of the data set specified bythe query. For example, the system may identify row identifiers of thelowest and highest rows that satisfy the query filters, and add aBETWEEN clause to the query that specifies an upper and lower boundequal to the determined highest and lowest row identifiers,respectively.

Continuing in block 330, the system determines one or more resourcebudgets that identify a threshold of resource usage to be consumed whileprocessing the query. The system will attempt to manage query processingin a manner that does not exceed the determined resource budgets. Thebudget may include a limit of memory usage, processing resources,network resources, storage resources, or any combination of resources.The system determines the budgets based on pre-configured settings orinformation received in association with the query. In some cases,particular client types may have an allowed resource usage or the systemadministrator may tune the resource budget to prevent paging or otherpotential performance-robbing events.

Continuing in block 340, the system begins processing the current recordrange. Based on a cursor indicating the current record and a BETWEENclause that specifies an upper limit to the range of records to process,the system proceeds with processing each row in the data set untileither a budget threshold or the end of the range is reached. Insubsequent iterations, the system continues processing the range byselecting the next row in the data set.

Continuing in decision block 350, if the system determines that a budgetthreshold has been reached, then the system continues at block 360, elsethe system continues at block 370. In some embodiments, the systemsamples the current resource usage and compares the usage to the budgetthresholds on a periodic schedule. The schedule may include making thedetermination every N records, every N seconds, or any other metricimplemented by the system. Checking the budget more frequently willresult in faster partitioning when the budget is close to exhausted, butwill also incur more processing to manage the budget. An administratoror system implementer may tune the schedule of checking the resourcebudgets to achieve an appropriate balance between the computational costof checking the budget and granularity of decision making when thebudget is reached.

Continuing in block 360, the system dynamically partitions the data setto reduce the size of the current range to stay within the determinedresource budgets. For example, if the system is currently processing allof the records in one partition, the system may divide the records inhalf into two partitions, and only process one-half of the record set inthe current range. This process is described further with respect toFIG. 4. The system can reduce the current range multiple times, asdetermined by the data, until a size is reached that can be processedwithin the budgeted resource constraints. After block 360, the systemloops to block 340 to continue processing the resized range of records.

Continuing in decision block 370, if processing of the current range iscomplete, then the system continues at block 380, else the system loopsto block 340 to continue processing the current range. The system cansplit a query into multiple queries each having a BETWEEN operator thatspecifies a different range of records. The system processes each rangeby iterating through the matching records with identifiers between thespecified values until the upper bound of the BETWEEN operator isreached.

Continuing in decision block 380, if there are additional ranges toprocess to satisfy the received query due to dynamic partitioning of thedata, then the system continues at block 390, else the system continuesat block 395. Continuing in block 390, the system selects the nextpartition range for processing. In some embodiments, the next rangeincludes all of the remaining records not previously processed. In otherwords, the system may optimistically assume that the remaining recordscan be processed within the resource budget without furtherpartitioning. If the assumption proves false as processing continues,then the system will dynamically partition the remaining records toproduce additional ranges that will be processed in subsequentiterations. After block 390, the system loops to block 340 to beginprocessing the selected next range.

Continuing in block 395, the system merges results of processing eachpartition range to produce a unified response to the received query. Thesteps used for merging results may vary based on the informationrequested by the query. For example, if the query requests a count ofrecords, then the merging may include adding counts of records producedby processing each partition. In the event of a requested distinctcount, the merging may include determining record distinctness betweenresult sets from each partition, and producing appropriate count totalsfrom there. In some cases, merging simply performs a classic hashapproach that operates on a hash table created by the first dynamicpartitioning phase. The dynamic portioning phase is fast and scalable,and the second phase can quickly determine distinct counts or performdata grouping from the resulting hash table. After block 395, thesesteps conclude.

FIG. 4 is a flow diagram that illustrates processing of the scalableanalysis to dynamically partition records in a data set while processinga query, in one embodiment. Typically, these steps occur dynamicallywhile processing a query like the described with reference to FIG. 3.When a budget threshold is reached or soon to be reached, the systemdynamically reduces the size of the current set of records beingprocessed, and thus increases the remaining records to be processed. Inthis way, the system ensures that the processing of each set of recordsstays within a budgeted set of resource thresholds.

Beginning in block 410, the system determines a current range size of aset of data records being processed. The current range size may includean entire set of records, in the case of no prior attempts to partitionthe data during query processing, or may include a subset of the entireset of records in the case of prior attempts to partition the data.Determining the current range size informs the system how muchpartitioning has occurred already so that a smaller partition can beselected.

Continuing in block 420, the system determines a new range size forprocessing records within a resource budget. For example, the system maycut the prior range size in half, or if the prior range size was alreadya half of the total range, the system may cut the prior range size to athird of the total range. The system selects a range size that isexpected to be processable within a specified resource budget. Thesystem may receive information such as a velocity at which memory usageis increasing to determine how much additional data can be processedwithin the budget. For some types of operations, such as data grouping,memory velocity is initially larger as new data values are encounteredbut velocity slows as the data is processed because new values are morerarely encountered.

Continuing in block 430, the system resizes the current processing rangebased on the determined new range size. In some cases, the system maymodify a BETWEEN clause of a query based on the new range size so thatan upper bound of record identifiers is reduced to encompass fewerrecords in the query.

Continuing in block 440, the system updates a remaining range size toinclude any records excluded from the current range size. The recordsnot processed in the current iteration will be processed in one or moresubsequent iterations. The system attempts to divide the data in amanner that will allow processing each iteration within the resourcebudget. After processing the current range, the system moves on to theremaining records, performing the same type of dynamic partitioninguntil all records responsive to the query have been processed.

Continuing in block 450, the system continues processing the resizedcurrent range until either the resource budget is again constrained orall records in the range have been processed. The system may performadditional partitioning by further reducing the current range size asneeded to process the current iteration within the resource budget, asshown further with reference to FIG. 3. After block 450, these stepsconclude.

In some embodiments, the scalable analysis system checks the currentresource usage against a budgeted resource usage every N records. Thesystem can check the budget according to a variety of heuristics,including dynamically determining the check frequency as the data isprocessed. For example, the system may initially check memory pressurefrequently, but if no pressure is detected or memory velocity (the rateof increase in memory usage) is low, the system may schedule the nextcheck for further out (e.g., wait more records). The system attempts toselect N so that the processing of the budget is not itself a strain oncomputational resources, while keeping the value low enough to detectmemory or other resource pressure early.

In some embodiments, the scalable analysis system produces a data cacheusing the dynamic partitioning steps described herein and then performsadditional operations to finalize the query results on the resultingdata cache. In many database query implementations, it is undesirable toperform complex operations on the first phase data cache because thedata cache is potentially large. The data cache produced by the dynamicpartitioning method described herein is reasonable enough in size thatoperations (such as determining a distinct count or grouping) can beperformed efficiently against the data cache. Thus, by generating thedata cache efficiently and then processing the data cache efficiently togenerate the desired query result, the system makes the whole operationefficient and scalable.

In some embodiments, the scalable analysis system performs parallelprocessing of dynamically partitioned ranges. Because each rangeoperates on an independent set of records, the system can process eachrange in parallel. Thus, as the system divides the data into partitions,the system may go ahead and begin processing some partitions at the sametime is others when appropriate computing resources are available (e.g.,additional processors) to more efficiently complete the whole operation.

In some embodiments, the scalable analysis system does not perform thedynamic partitioning method unless the table against which the query isexecuted exceeds a threshold size. For small tables, the complexity ofthe dynamic partitioning is unnecessary and may not produce a noticeablebenefit. Thus, the system may establish a threshold up to which a naïveor straightforward approach to the query is used, and only use thedynamic partitioning method for larger tables. In some embodiments, thesystem may start processing all queries using a naïve approach and thenswitch to a dynamic partitioning approach as resources come underpressure during processing of the query.

From the foregoing, it will be appreciated that specific embodiments ofthe scalable analysis system have been described herein for purposes ofillustration, but that various modifications may be made withoutdeviating from the spirit and scope of the invention. Accordingly, theinvention is not limited except as by the appended claims.

We claim:
 1. A computer-implemented method for data set processing, themethod comprising: in response to a determination that a resource usagethreshold has been reached while processing records of a data set usinga processing range of a first size, dynamically reducing the processingrange to a second size that is less than the first size, wherein thesecond size is based at least in part on a quantity of records expectedto be processable within a resource budget; processing a first subset ofthe records with the processing range of the second size; processing asecond subset of the records with the processing range of the secondsize, wherein the second subset of the records does not overlap with thefirst subset of the records; and merging results of the processing ofthe first subset with results of the processing of the second subset. 2.The method of claim 1, wherein the determination that the resource usagethreshold has been reached comprises receiving information describing avelocity at which memory usage is increasing.
 3. The method of claim 1,wherein the velocity slows as the data set is processed.
 4. The methodof claim 1, wherein the records not processed in the first subset or inthe second subset are to be processed in one or more other subsets. 5.The method of claim 4, wherein the first subset and second subsetrepresent a partitioning of the data set in a manner that allowsprocessing of the subsets within the resource budget.
 6. The method ofclaim 1, further comprising: processing a third subset of the recordswith the processing range of the second size.
 7. The method of claim 1,further comprising: determining that the resource usage threshold hasbeen reached while processing the records of the data set using theprocessing range of the second size; and in response to the determiningthat the resource usage threshold has been reached while processing therecords of the data set using the processing range of the second size,further reducing the processing range.
 8. A system for processing dataset queries, the system comprising: at least one processor; at least onememory device; wherein the at least one memory device and the at leastone processor are respectively configured to store and executeinstructions for causing the computing device to perform operations, theoperations including: receiving a request for a query result; inresponse to the request, beginning a processing of the data set using aprocessing range setting of an initial value; determining that aresource usage threshold has been reached in conjunction with theprocessing of the data set using the processing range setting of theinitial value; in response to the determining, dynamically partitioningthe data set into multiple subsets, a size of the subsets being based atleast in part on a quantity of records expected to be processable withinthe resource usage threshold, wherein the subsets do not overlap witheach other; processing the multiple subsets; and merging results of theprocessing the multiple subsets into a unified response to the request.9. The system of claim 8, the initial value represents an entirety ofthe data set.
 10. The system of claim 8, wherein the resource usagethreshold represents a memory usage limit for the processing of thedataset.
 11. The system of claim 8, wherein the resource usage thresholdis based on at least one of pre-configured settings or informationreceived in association with the request.
 12. The system of claim 8,wherein the determining that the resource usage threshold has beenreached comprises determining that a memory usage velocity will lead toexceeding a budgeted memory usage before a next budget check.
 13. Thesystem of claim 8, wherein the determining that the resource usagethreshold has been reached comprises sampling a current resource usageand comparing the current usage to the budget thresholds on a periodicschedule.
 14. The system of claim 8, wherein the dynamicallypartitioning comprises dividing the data set into the multiple subsets.15. The system of claim 8, wherein the dynamically partitioningcomprises, after a determination that the resource usage threshold hasbeen reached after a first attempt at dynamic partitioning, performing asecond dynamic partitioning.
 16. A computer-implemented method for dataset processing, the method comprising: in response to a determinationthat a resource usage threshold has been or would be reached whileprocessing records of a data set using a processing range of a firstsize, dynamically reducing the processing range to a second size that isless than the first size, wherein the second size is based at least inpart on a quantity of records expected to be processable; and processinga plurality of dynamically partitioned subsets of the records of data inaccordance with the processing range of the second size, wherein thedynamically partitioned subsets of the plurality of dynamicallypartitioned subsets do not overlap with each other.
 17. The method ofclaim 16, wherein the quantity of records expected to be processable isbased at least in part on a second order function corresponding tomemory usage for data set processing.
 18. The method of claim 16,wherein the processing of the plurality of dynamically partitionedsubsets includes the processing of a query operation over a firstportion of the data set.
 19. The method of claim 18, wherein the secondsize is also based on a memory usage limit for data set processing. 20.The method of claim 16, the method further comprising: adding a BETWEENoperator to a WHERE clause for a query.